#define CENTI_TO_MICRO(t) ((t) * 10000) /* Centiseconds to Microseconds */
#define MICRO_TO_CENTI(t) ((t) / 10000) /* Centiseconds to Microseconds */
+constexpr int kDatumOSGB36 = 86; // GPS_Lookup_Datum_Index("OSGB36")
+constexpr int kDautmWGS84 = 118; // GPS_Lookup_Datum_Index("WGS 84")
+
/* Pathname separator character */
#if __WIN32__
# define GB_PATHSEP '\\'
#define GRID_INDEX_MIN grid_lat_lon_ddd
#define GRID_INDEX_MAX grid_swiss
-#define DATUM_OSGB36 86
-#define DATUM_WGS84 118
-
/* bit manipulation functions (util.c) */
char gb_getbit(const void* buf, uint32_t nr);
#define unknown_alt -99999999.0
#define unknown_color -1
-// TODO: this is a (probably temporary) shim for the C->QString conversion.
-// It's here instead of gps to avoid C/C++ linkage issues.
-int32_t GPS_Lookup_Datum_Index(const QString& n);
-
#endif // DEFS_H_INCLUDED_
if (idatum < 0) {
fatal(MYNAME ": Unknown GPSMapDatum \"%s\"!\n", datum);
}
- if (idatum != DATUM_WGS84) {
+ if (idatum != kDautmWGS84) {
GPS_Math_WGS84_To_Known_Datum_M(wpt->latitude, wpt->longitude, 0.0,
&wpt->latitude, &wpt->longitude, &alt, idatum);
}
{
double alt;
- if (datum_index == DATUM_WGS84) {
+ if (datum_index == kDautmWGS84) {
*dest_lat = wpt->latitude;
*dest_lon = wpt->longitude;
} else GPS_Math_WGS84_To_Known_Datum_M(wpt->latitude, wpt->longitude, 0.0,
switch (grid_index) {
case grid_bng: /* force datum to "Ord Srvy Grt Britn" */
- datum_index = DATUM_OSGB36;
+ datum_index = kDatumOSGB36;
break;
case grid_swiss: /* force datum to WGS84 */
- datum_index = DATUM_WGS84;
+ datum_index = kDautmWGS84;
break;
default:
datum_index = gt_lookup_datum_index(datum_str, MYNAME);
double lambda0, double E0, double N0);
int32 GPS_Lookup_Datum_Index(const char* n);
+ int32 GPS_Lookup_Datum_Index(const QString& n);
const char* GPS_Math_Get_Datum_Name(int datum_index);
#endif
*/
+#include <cassert> // for assert
#include <clocale> // for setlocale, LC_NUMERIC, LC_TIME
#include <csignal> // for signal, SIGINT, SIG_ERR
#include <cstdio> // for printf, fflush, fgetc, fprintf, stderr, stdin, stdout
#include "format.h" // for Format
#include "gbversion.h" // for VERSION_SHA
#include "inifile.h" // for inifile_done, inifile_init
+#include "jeeps/gpsmath.h" // for GPS_Lookup_Datum_Index
#include "session.h" // for start_session, session_exit, session_init
#include "src/core/datetime.h" // for DateTime
#include "src/core/file.h" // for File
global_opts.inifile = inifile_init(QString(), MYNAME);
}
+ assert(GPS_Lookup_Datum_Index("OSGB36") == kDatumOSGB36);
+ assert(GPS_Lookup_Datum_Index("WGS 84") == kDautmWGS84);
+
Vecs::Instance().init_vecs();
FilterVecs::Instance().init_filter_vecs();
session_init();
// This also indicates to nmea_release_wpt that ownership has been
// transferred to either the global_waypoint_list or global_track_list.
wpt->extra_data = nullptr;
- if (datum != DATUM_WGS84) {
+ if (datum != kDautmWGS84) {
double lat, lon, alt;
GPS_Math_Known_Datum_To_WGS84_M(
wpt->latitude, wpt->longitude, 0,
{
curr_waypt = nullptr;
last_waypt = nullptr;
- datum = DATUM_WGS84;
+ datum = kDautmWGS84;
had_checksum = false;
CHECK_BOOL(opt_gprmc);
static void
ozi_convert_datum(Waypoint* wpt)
{
- if (datum != DATUM_WGS84) {
+ if (datum != kDautmWGS84) {
double lat, lon, alt;
GPS_Math_Known_Datum_To_WGS84_M(wpt->latitude, wpt->longitude, 0.0,
&lat, &lon, &alt, datum);
break;
case grid_bng:
- datum = DATUM_WGS84; /* fix */
+ datum = kDautmWGS84; /* fix */
format = "%2s %lf %lf%n";
ct = sscanf(str, format,
map, &lx, &ly,
case grid_swiss: {
double east, north;
- datum = DATUM_WGS84; /* fix */
+ datum = kDautmWGS84; /* fix */
format = "%lf %lf%n";
ct = sscanf(str, format,
&east, &north, &result);
lon = -lon;
}
- if (datum != DATUM_WGS84) {
+ if (datum != kDautmWGS84) {
double alt;
GPS_Math_Known_Datum_To_WGS84_M(lat, lon, 0.0,
&lat, &lon, &alt, datum);
&wpt->latitude, &wpt->longitude, MYNAME);
/* coordinates from parse_coordinates are in WGS84
don't convert a second time */
- src_datum = DATUM_WGS84;
+ src_datum = kDautmWGS84;
break;
case fld_bng:
- parse_coordinates(value, DATUM_OSGB36, grid_bng,
+ parse_coordinates(value, kDatumOSGB36, grid_bng,
&wpt->latitude, &wpt->longitude, MYNAME);
/* coordinates from parse_coordinates are in WGS84
don't convert a second time */
- src_datum = DATUM_WGS84;
+ src_datum = kDautmWGS84;
break;
case fld_bng_zone:
break;
case fld_swiss:
- parse_coordinates(value, DATUM_WGS84, grid_swiss,
+ parse_coordinates(value, kDautmWGS84, grid_swiss,
&wpt->latitude, &wpt->longitude, MYNAME);
/* coordinates from parse_coordinates are in WGS84
don't convert a second time */
- src_datum = DATUM_WGS84;
+ src_datum = kDautmWGS84;
break;
case fld_swiss_easting:
fatal(MYNAME ": Unable to convert BNG coordinates (%s %.f %.f)!\n",
bng_zone, bng_easting, bng_northing);
}
- src_datum = DATUM_WGS84; /* don't convert afterwards */
+ src_datum = kDautmWGS84; /* don't convert afterwards */
} else if ((swiss_easting != kUnicsvUnknown) && (swiss_northing != kUnicsvUnknown)) {
GPS_Math_Swiss_EN_To_WGS84(swiss_easting, swiss_northing,
&wpt->latitude, &wpt->longitude);
- src_datum = DATUM_WGS84; /* don't convert afterwards */
+ src_datum = kDautmWGS84; /* don't convert afterwards */
}
}
- if ((src_datum != DATUM_WGS84) &&
+ if ((src_datum != kDautmWGS84) &&
(wpt->latitude != kUnicsvUnknown) && (wpt->longitude != kUnicsvUnknown)) {
double alt;
GPS_Math_Known_Datum_To_WGS84_M(wpt->latitude, wpt->longitude, 0.0,
QString shortname = wpt->shortname;
garmin_fs_t* gmsd = garmin_fs_t::find(wpt);
- if (unicsv_datum_idx == DATUM_WGS84) {
+ if (unicsv_datum_idx == kDautmWGS84) {
lat = wpt->latitude;
lon = wpt->longitude;
alt = wpt->altitude;
memset(&unicsv_outp_flags, 0, sizeof(unicsv_outp_flags));
unicsv_grid_idx = grid_unknown;
- unicsv_datum_idx = DATUM_WGS84;
+ unicsv_datum_idx = kDautmWGS84;
unicsv_fieldsep = kUnicsvFieldSep;
unicsv_waypt_ct = 0;
/* force datum to "Ord Srvy Grt Britn" / OSGB36 */
/* ! ignore parameter "Datum" ! */
{
- unicsv_datum_idx = DATUM_OSGB36;
+ unicsv_datum_idx = kDatumOSGB36;
} else if (unicsv_grid_idx == grid_swiss)
/* ! ignore parameter "Datum" ! */
{
- unicsv_datum_idx = DATUM_WGS84; /* internal, becomes CH1903 */
+ unicsv_datum_idx = kDautmWGS84; /* internal, becomes CH1903 */
} else {
unicsv_datum_idx = gt_lookup_datum_index(opt_datum, MYNAME);
}
break;
/* SPECIAL COORDINATES/GRID */
case XcsvStyle::XT_MAP_EN_BNG:
- parse_coordinates(s, DATUM_OSGB36, grid_bng,
+ parse_coordinates(s, kDatumOSGB36, grid_bng,
&wpt->latitude, &wpt->longitude, MYNAME);
break;
case XcsvStyle::XT_UTM_ZONE:
wpt_tmp->longitude = -wpt_tmp->longitude;
}
- if ((xcsv_file->gps_datum_idx > -1) && (xcsv_file->gps_datum_idx != gps_datum_wgs84)) {
+ if ((xcsv_file->gps_datum_idx > -1) && (xcsv_file->gps_datum_idx != kDautmWGS84)) {
double alt;
GPS_Math_Known_Datum_To_WGS84_M(wpt_tmp->latitude, wpt_tmp->longitude, 0.0,
&wpt_tmp->latitude, &wpt_tmp->longitude, &alt, xcsv_file->gps_datum_idx);
&wpt_tmp->longitude,
parse_data.utm_easting, parse_data.utm_northing,
parse_data.utm_zone, parse_data.utm_zonec,
- DATUM_WGS84);
+ kDautmWGS84);
}
if (parse_data.link_) {
description = shortname;
}
- if ((xcsv_file->gps_datum_idx > -1) && (xcsv_file->gps_datum_idx != gps_datum_wgs84)) {
+ if ((xcsv_file->gps_datum_idx > -1) && (xcsv_file->gps_datum_idx != kDautmWGS84)) {
double alt;
GPS_Math_WGS84_To_Known_Datum_M(latitude, longitude, 0.0,
&latitude, &longitude, &alt, xcsv_file->gps_datum_idx);
if (xcsv_file->gps_datum_idx < 0) {
fatal(MYNAME ": datum \"%s\" is not supported.", qPrintable(datum_name));
}
- assert(gps_datum_wgs84 == GPS_Lookup_Datum_Index("WGS 84"));
}
void
if (xcsv_file->gps_datum_idx < 0) {
fatal(MYNAME ": datum \"%s\" is not supported.", qPrintable(datum_name));
}
- assert(gps_datum_wgs84 == GPS_Lookup_Datum_Index("WGS 84"));
}
void
return (a / 86400.0) + 25569.0;
}
- static constexpr int gps_datum_wgs84 = 118; // GPS_Lookup_Datum_Index("WGS 84")
-
/* Member Functions */
static QDateTime yyyymmdd_to_time(const QString& s);